package com.cjl.dental_clinic.base;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @author cjl
 * @create 2024/01/01 11:15
 **/
@Data
public class BaseEntity implements Serializable {

    @TableId(value = "id",type = IdType.AUTO)
    private Integer id;


    /**
     *
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @TableField(value = "created_at",fill= FieldFill.INSERT)
    private Date createdAt;

    /**
     *
     */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @TableField(value = "updated_at",fill= FieldFill.INSERT_UPDATE)
    private Date updatedAt = DateUtil.date();


    /**
     *
     */
    @TableField(value = "is_del")
    @TableLogic
    private Integer isDel;

    public void initCreateUser(){
        this.createdAt = new Date();
        this.updatedAt = new Date();
    }

    public void initUpdateUser(){
        this.updatedAt = new Date();
    }
}
